from toee import *
from council import *
from py00439script_daemon import record_time_stamp, get_v, set_v, npc_set, npc_unset, npc_get, tsc, within_rect_by_corners

def san_dialog( attachee, triggerer ):
	if (game.leader.reputation_has(32) == 1 or game.leader.reputation_has(30) == 1 or game.leader.reputation_has(29) == 1):
		attachee.float_line(11004,triggerer)
	elif (attachee.map == 5001) and (game.global_vars[4] <= 4):
		triggerer.begin_dialog( attachee, 110 )
	else:
		triggerer.begin_dialog( attachee, 1 )
	return SKIP_DEFAULT

def san_dying( attachee, triggerer ):
	if (game.quests[9].state >= qs_accepted):
		game.global_vars[4] = 1
	if (game.party[0].reputation_has(9) == 0):
		game.party[0].reputation_add(9)
	return RUN_DEFAULT

def san_first_heartbeat( attachee, triggerer ):
	if (attachee.map == 5001) and (game.global_vars[4] <= 1):
		if (game.quests[9].state == qs_accepted):
			attachee.object_flag_unset(OF_OFF)
		else:
			attachee.object_flag_set(OF_OFF)
	elif (game.global_vars[4] == 5):
		attachee.object_flag_unset(OF_OFF)
	elif (game.global_vars[4] == 3):
		game.global_vars[4] = 4
		attachee.standpoint_set( STANDPOINT_NIGHT, 230 )
		attachee.standpoint_set( STANDPOINT_DAY, 230 )
		attachee.object_flag_set(OF_OFF)
		game.global_flags[204] = 1
		game.global_vars[24] = game.global_vars[24] + 1
		if (game.party[0].reputation_has( 5 ) == 0):
			game.party[0].reputation_add( 5 )
		if ((game.global_vars[24] >= 3) and (game.party[0].reputation_has( 6 ) == 0)):
			game.party[0].reputation_add( 6 )
	elif (game.quests[9].state >= qs_completed):
		attachee.object_flag_set(OF_OFF)
	else:
		attachee.object_flag_unset(OF_OFF)
	return RUN_DEFAULT